package com.yushealth.prostate.fingerdanceforprostate;

import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

public class AlarmActivity extends AppCompatActivity {

    Ringtone ringtone;
    TextView message;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alarm);

        message = (TextView) findViewById(R.id.message);
        Bundle bundle = getIntent().getExtras();
        message.setText(bundle.getString("title"));
        // 播放声音
        Uri alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        if (alarmUri == null) {
            alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        }
        ringtone = RingtoneManager.getRingtone(getApplication(), alarmUri);
        ringtone.play();
    }

    public void btnOkClick(View view) {
        ringtone.stop();
        finish();
    }
}
